home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / Delphi 3.0 / DATA.Z / mapi.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-01-29  |  18.6 KB  |  494 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Runtime Library                          }
  5. {       Simple MAPI Interface Unit                      }
  6. {                                                       }
  7. {       Copyright (c) 1996,97 Borland International     }
  8. {                                                       }
  9. {*******************************************************}
  10.  
  11. unit Mapi;
  12.  
  13. {NOTE: Do not place the $NOPACKAGEUNIT directive in this file}
  14.  
  15. interface
  16.  
  17. uses Windows;
  18.  
  19. {
  20.   Messaging Applications Programming Interface.
  21.  
  22.   Purpose:
  23.  
  24.     This file defines the structures and constants used by that
  25.     subset of the Messaging Applications Programming Interface
  26.     which is supported under Windows by Microsoft Mail for PC
  27.     Networks version 3.x.
  28. }
  29.  
  30.  
  31. type
  32.   FLAGS = Cardinal;
  33.   LHANDLE = Cardinal;
  34.   PLHANDLE = ^Cardinal;
  35.  
  36. const
  37.   lhSessionNull = (0);
  38.  
  39. type
  40.   PMapiFileDesc = ^TMapiFileDesc;
  41.   TMapiFileDesc = packed record
  42.     ulReserved: Cardinal;        { Reserved for future use (must be 0)     }
  43.     flFlags: Cardinal;           { Flags                                   }
  44.     nPosition: Cardinal;         { character in text to be replaced by attachment }
  45.     lpszPathName: LPSTR;         { Full path name of attachment file       }
  46.     lpszFileName: LPSTR;         { Original file name (optional)           }
  47.     lpFileType: Pointer;         { Attachment file type (can be lpMapiFileTagExt) }
  48.   end;
  49.  
  50. const
  51.   MAPI_OLE = $00000001; 
  52.   MAPI_OLE_STATIC = $00000002; 
  53.  
  54.  
  55. type
  56.   PMapiFileTagExt = ^TMapiFileTagExt;
  57.   TMapiFileTagExt = packed record 
  58.     ulReserved: Cardinal;       { Reserved, must be zero.                  }
  59.     cbTag: Cardinal;            { Size (in bytes) of                       }
  60.     lpTag: PByte;               { X.400 OID for this attachment type       }
  61.     cbEncoding: Cardinal;       { Size (in bytes) of                       }
  62.     lpEncoding: PByte;          { X.400 OID for this attachment's encoding }
  63.   end;
  64.  
  65.  
  66.   PMapiRecipDesc = ^TMapiRecipDesc;
  67.   TMapiRecipDesc = packed record 
  68.     ulReserved: Cardinal;       { Reserved for future use                  }
  69.     ulRecipClass: Cardinal;     { Recipient class                          }
  70.                                 { MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG    }
  71.     lpszName: LPSTR;            { Recipient name                           }
  72.     lpszAddress: LPSTR;         { Recipient address (optional)             }
  73.     ulEIDSize: Cardinal;        { Count in bytes of size of pEntryID       }
  74.     lpEntryID: Pointer;         { System-specific recipient reference      }
  75.   end;
  76.  
  77. const
  78.   MAPI_ORIG = 0;                { Recipient is message originator          }
  79.   MAPI_TO = 1;                  { Recipient is a primary recipient         }
  80.   MAPI_CC = 2;                  { Recipient is a copy recipient            }
  81.   MAPI_BCC = 3;                 { Recipient is blind copy recipient        }
  82.  
  83. type
  84.   PMapiMessage = ^TMapiMessage;
  85.   TMapiMessage = packed record
  86.     ulReserved: Cardinal;         { Reserved for future use (M.B. 0)       }
  87.     lpszSubject: LPSTR;           { Message Subject                        }
  88.     lpszNoteText: LPSTR;          { Message Text                           }
  89.     lpszMessageType: LPSTR;       { Message Class                          }
  90.     lpszDateReceived: LPSTR;      { in YYYY/MM/DD HH:MM format             }
  91.     lpszConversationID: LPSTR;    { conversation thread ID                 }
  92.     flFlags: FLAGS;               { unread,return receipt                  }
  93.     lpOriginator: PMapiRecipDesc; { Originator descriptor                  }
  94.     nRecipCount: Cardinal;        { Number of recipients                   }
  95.     lpRecips: PMapiRecipDesc;     { Recipient descriptors                  }
  96.     nFileCount: Cardinal;         { # of file attachments                  }
  97.     lpFiles: PMapiFileDesc;       { Attachment descriptors                 }
  98.   end;
  99.  
  100. const
  101.   MAPI_UNREAD = $00000001; 
  102.   MAPI_RECEIPT_REQUESTED = $00000002; 
  103.   MAPI_SENT = $00000004; 
  104.  
  105.  
  106. { Entry points. }
  107.  
  108. { flFlags values for Simple MAPI entry points. All documented flags are
  109.   shown for each call. Duplicates are commented out but remain present
  110.   for every call. }
  111.  
  112. { MAPILogon() flags. }
  113.  
  114.   MAPI_LOGON_UI = $00000001;                { Display logon UI             }
  115.   MAPI_PASSWORD_UI = $00020000;             { prompt for password only     }
  116.   MAPI_NEW_SESSION = $00000002;             { Don't use shared session     }
  117.   MAPI_FORCE_DOWNLOAD = $00001000;          { Get new mail before return   }
  118.   MAPI_ALLOW_OTHERS = $00000008;            { Make this a shared session   (removed from 4.0 SDK) }
  119.   MAPI_EXPLICIT_PROFILE = $00000010;        { Don't use default profile    (removed from 4.0 SDK) }
  120.   MAPI_EXTENDED = $00000020;                { Extended MAPI Logon          }
  121.   MAPI_USE_DEFAULT = $00000040;             { Use default profile in logon (removed from 4.0 SDK) }
  122.  
  123.   MAPI_SIMPLE_DEFAULT = MAPI_LOGON_UI or MAPI_FORCE_DOWNLOAD or MAPI_ALLOW_OTHERS; { removed from 4.0 SDK }
  124.   MAPI_SIMPLE_EXPLICIT = MAPI_NEW_SESSION or MAPI_FORCE_DOWNLOAD or MAPI_EXPLICIT_PROFILE; { removed from 4.0 SDK } 
  125.  
  126. { MAPILogoff() flags.      }
  127.  
  128.   MAPI_LOGOFF_SHARED = $00000001;           { Close all shared sessions  (removed from 4.0 SDK)  }
  129.   MAPI_LOGOFF_UI = $00000002;               { It's OK to present UI      (removed from 4.0 SDK)  }
  130.  
  131. { MAPISendMail() flags.    }
  132.  
  133. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  134. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  135.   MAPI_DIALOG = $00000008;                  { Display a send note UI       }
  136. { # define MAPI_USE_DEFAULT     0x00000040     Use default profile in logon }
  137.  
  138. { MAPIFindNext() flags.    }
  139.  
  140.   MAPI_UNREAD_ONLY = $00000020;             { Only unread messages         }
  141.   MAPI_GUARANTEE_FIFO = $00000100;          { use date order               }
  142.   MAPI_LONG_MSGID = $00004000;              { allow 512 char returned ID   }
  143.  
  144. { MAPIReadMail() flags.    }
  145.  
  146.   MAPI_PEEK = $00000080;                    { Do not mark as read.         }
  147.   MAPI_SUPPRESS_ATTACH = $00000800;         { header + body, no files      }
  148.   MAPI_ENVELOPE_ONLY = $00000040;           { Only header information      }
  149.   MAPI_BODY_AS_FILE = $00000200; 
  150.  
  151. { MAPISaveMail() flags.    }
  152.  
  153. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  154. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  155. { #define MAPI_LONG_MSGID      0x00004000  /* allow 512 char returned ID   }
  156.  
  157. { MAPIAddress() flags.     }
  158.  
  159. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  160. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  161.  
  162. { MAPIDetails() flags.     }
  163.  
  164. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  165. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  166.   MAPI_AB_NOMODIFY = $00000400;             { Don't allow mods of AB entries }
  167.  
  168. { MAPIResolveName() flags. }
  169.  
  170. { #define MAPI_LOGON_UI        0x00000001     Display logon UI             }
  171. { #define MAPI_NEW_SESSION     0x00000002     Don't use shared session     }
  172. { #define MAPI_DIALOG          0x00000008     Prompt for choices if ambiguous }
  173. { #define MAPI_AB_NOMODIFY     0x00000400     Don't allow mods of AB entries }
  174.  
  175. type
  176.   PFNMapiLogon = ^TFNMapiLogOn;
  177.   TFNMapiLogOn = function(ulUIParam: Cardinal; lpszProfileName: LPSTR; 
  178.     lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  179.     lplhSession: PLHANDLE): Cardinal stdcall;
  180.  
  181.   PFNMapiLogOff = ^TFNMapiLogOff;
  182.   TFNMapiLogOff = function(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;
  183.     ulReserved: Cardinal): Cardinal stdcall;
  184.  
  185.   PFNMapiSendMail = ^TFNMapiSendMail;
  186.   TFNMapiSendMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  187.     var lpMessage: TMapiMessage; flFlags: FLAGS;
  188.     ulReserved: Cardinal): Cardinal stdcall;
  189.  
  190.   PFNMapiSendDocuments = ^TFNMapiSendDocuments;
  191.   TFNMapiSendDocuments = function(ulUIParam: Cardinal; lpszDelimChar: LPSTR;
  192.     lpszFilePaths: LPSTR; lpszFileNames: LPSTR;
  193.     ulReserved: Cardinal): Cardinal stdcall;
  194.  
  195.   PFNMapiFindNext = ^TFNMapiFindNext;
  196.   TFNMapiFindNext = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  197.     lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  198.     ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal stdcall;
  199.  
  200.   PFNMapiReadMail = ^TFNMapiReadMail;
  201.   TFNMapiReadMail = function(lhSession: LHANDLE; ulUIParam: Cardinal;
  202.     lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  203.     var lppMessage: PMapiMessage): Cardinal stdcall;
  204.  
  205.   PFNMapiSaveMail = ^TFNMapiSaveMail;
  206.   TFNMapiSaveMail = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  207.     var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal; 
  208.     lpszMessageID: LPSTR): Cardinal stdcall;
  209.  
  210.   PFNMapiDeleteMail = ^TFNMapiDeleteMail;
  211.   TFNMapiDeleteMail = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  212.     lpszMessageID: LPSTR; flFlags: FLAGS; 
  213.     ulReserved: Cardinal): Cardinal stdcall;
  214.  
  215.   PFNMapiFreeBuffer = ^TFNMapiFreeBuffer;
  216.   TFNMapiFreeBuffer = function(pv: Pointer): Cardinal stdcall;
  217.  
  218.   PFNMapiAddress = ^TFNMapiAddress;
  219.   TFNMapiAddress = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  220.     lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR; 
  221.     nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS; 
  222.     ulReserved: Cardinal; lpnNewRecips: PULONG; 
  223.     var lppNewRecips: PMapiRecipDesc): Cardinal stdcall;
  224.  
  225.   PFNMapiDetails = ^TFNMapiDetails;
  226.   TFNMapiDetails = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  227.     var lpRecip: TMapiRecipDesc; flFlags: FLAGS; 
  228.     ulReserved: Cardinal): Cardinal stdcall;
  229.  
  230.   PFNMapiResolveName = ^TFNMapiResolveName;
  231.   TFNMapiResolveName = function(lhSession: LHANDLE; ulUIParam: Cardinal; 
  232.     lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  233.     var lppRecip: PMapiRecipDesc): Cardinal stdcall;
  234.  
  235. const
  236.   SUCCESS_SUCCESS = 0; 
  237.   MAPI_USER_ABORT = 1; 
  238.   MAPI_E_USER_ABORT                  = MAPI_USER_ABORT;
  239.   MAPI_E_FAILURE = 2; 
  240.   MAPI_E_LOGON_FAILURE = 3; 
  241.   MAPI_E_LOGIN_FAILURE               = MAPI_E_LOGON_FAILURE; 
  242.   MAPI_E_DISK_FULL = 4; 
  243.   MAPI_E_INSUFFICIENT_MEMORY = 5; 
  244.   MAPI_E_ACCESS_DENIED = 6; 
  245.   MAPI_E_TOO_MANY_SESSIONS = 8; 
  246.   MAPI_E_TOO_MANY_FILES = 9; 
  247.   MAPI_E_TOO_MANY_RECIPIENTS = 10; 
  248.   MAPI_E_ATTACHMENT_NOT_FOUND = 11;
  249.   MAPI_E_ATTACHMENT_OPEN_FAILURE = 12;
  250.   MAPI_E_ATTACHMENT_WRITE_FAILURE = 13;
  251.   MAPI_E_UNKNOWN_RECIPIENT = 14;
  252.   MAPI_E_BAD_RECIPTYPE = 15;
  253.   MAPI_E_NO_MESSAGES = 16;
  254.   MAPI_E_INVALID_MESSAGE = 17;
  255.   MAPI_E_TEXT_TOO_LARGE = 18;
  256.   MAPI_E_INVALID_SESSION = 19;
  257.   MAPI_E_TYPE_NOT_SUPPORTED = 20;
  258.   MAPI_E_AMBIGUOUS_RECIPIENT = 21;
  259.   MAPI_E_AMBIG_RECIP                 = MAPI_E_AMBIGUOUS_RECIPIENT;
  260.   MAPI_E_MESSAGE_IN_USE = 22;
  261.   MAPI_E_NETWORK_FAILURE = 23;
  262.   MAPI_E_INVALID_EDITFIELDS = 24;
  263.   MAPI_E_INVALID_RECIPS = 25;
  264.   MAPI_E_NOT_SUPPORTED = 26;
  265.  
  266.  
  267. { Delphi wrapper calls around Simple MAPI }
  268.  
  269. function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR;
  270.   lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  271.   lplhSession: PLHANDLE): Cardinal;
  272.  
  273. function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS;
  274.   ulReserved: Cardinal): Cardinal;
  275.  
  276. function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  277.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  278.  
  279. function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR;
  280.   lpszFilePaths: LPSTR; lpszFileNames: LPSTR; ulReserved: Cardinal): Cardinal;
  281.  
  282. function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
  283.   lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  284.   ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;
  285.  
  286. function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  287.   lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  288.   var lppMessage: PMapiMessage): Cardinal;
  289.  
  290. function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  291.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
  292.   lpszMessageID: LPSTR): Cardinal;
  293.  
  294. function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  295.   lpszMessageID: LPSTR; flFlags: FLAGS;
  296.   ulReserved: Cardinal): Cardinal;
  297.  
  298. function MapiFreeBuffer(pv: Pointer): Cardinal;
  299.  
  300. function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
  301.   lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
  302.   nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
  303.   ulReserved: Cardinal; lpnNewRecips: PULONG;
  304.   var lppNewRecips: PMapiRecipDesc): Cardinal;
  305.  
  306. function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
  307.   var lpRecip: TMapiRecipDesc; flFlags: FLAGS;
  308.   ulReserved: Cardinal): Cardinal;
  309.  
  310. function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
  311.   lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  312.   var lppRecip: PMapiRecipDesc): Cardinal;
  313.  
  314. var
  315.   MAPIDLL: string = 'MAPI32.DLL';
  316.  
  317. implementation
  318.  
  319. var
  320.   MAPIModule: HModule = 0;
  321.   LogOn: TFNMapiLogOn = nil;
  322.   LogOff: TFNMapiLogOff = nil;
  323.   SendMail: TFNMapiSendMail = nil;
  324.   SendDocuments: TFNMapiSendDocuments = nil;
  325.   FindNext: TFNMapiFindNext = nil;
  326.   ReadMail: TFNMapiReadMail = nil;
  327.   SaveMail: TFNMapiSaveMail = nil;
  328.   DeleteMail: TFNMapiDeleteMail = nil;
  329.   FreeBuffer: TFNMapiFreeBuffer = nil;
  330.   Address: TFNMapiAddress = nil;
  331.   Details: TFNMapiDetails = nil;
  332.   ResolveName: TFNMapiResolveName = nil;
  333.  
  334. procedure InitMapi;
  335. begin
  336.   if MAPIModule = 0 then
  337.     MAPIModule := LoadLibrary(PChar(MAPIDLL));
  338. end;
  339.  
  340. function MapiLogOn(ulUIParam: Cardinal; lpszProfileName: LPSTR; 
  341.   lpszPassword: LPSTR; flFlags: FLAGS; ulReserved: Cardinal; 
  342.   lplhSession: PLHANDLE): Cardinal;
  343. begin
  344.   InitMapi;
  345.   if @LogOn = nil then
  346.     @LogOn := GetProcAddress(MAPIModule, 'MAPILogon');
  347.   if @LogOn <> nil then
  348.     Result := LogOn(ulUIParam, lpszProfileName, lpszPassword, flFlags,
  349.       ulReserved, lplhSession)
  350.   else Result := 1;
  351. end;
  352.  
  353. function MapiLogOff(lhSession: LHANDLE; ulUIParam: Cardinal; flFlags: FLAGS; 
  354.   ulReserved: Cardinal): Cardinal;
  355. begin
  356.   InitMapi;
  357.   if @LogOff = nil then
  358.     @LogOff := GetProcAddress(MAPIModule, 'MAPILogoff');
  359.   if @LogOff <> nil then
  360.     Result := LogOff(lhSession, ulUIParam, flFlags, ulReserved)
  361.   else Result := 1;
  362. end;
  363.  
  364. function MapiSendMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  365.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  366. begin
  367.   InitMapi;
  368.   if @SendMail = nil then
  369.     @SendMail := GetProcAddress(MAPIModule, 'MAPISendMail');
  370.   if @SendMail <> nil then
  371.     Result := SendMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved)
  372.   else Result := 1;
  373. end;
  374.  
  375. function MapiSendDocuments(ulUIParam: Cardinal; lpszDelimChar: LPSTR; 
  376.   lpszFilePaths: LPSTR; lpszFileNames: LPSTR; 
  377.   ulReserved: Cardinal): Cardinal;
  378. begin
  379.   InitMapi;
  380.   if @SendDocuments = nil then
  381.     @SendDocuments := GetProcAddress(MAPIModule, 'MAPISendDocuments');
  382.   if @SendDocuments <> nil then
  383.     Result := SendDocuments(ulUIParam, lpszDelimChar, lpszFilePaths,
  384.       lpszFileNames, ulReserved)
  385.   else Result := 1;
  386. end;
  387.  
  388. function MapiFindNext(lhSession: LHANDLE; ulUIParam: Cardinal;
  389.   lpszMessageType: LPSTR; lpszSeedMessageID: LPSTR; flFlags: FLAGS;
  390.   ulReserved: Cardinal; lpszMessageID: LPSTR): Cardinal;
  391. begin
  392.   InitMapi;
  393.   if @FindNext = nil then
  394.     @FindNext := GetProcAddress(MAPIModule, 'MAPIFindNext');
  395.   if @FindNext <> nil then
  396.     Result := FindNext(lhSession, ulUIParam, lpszMessageType,
  397.       lpszSeedMessageID, flFlags, ulReserved, lpszMessageID)
  398.   else Result := 1;
  399. end;
  400.  
  401. function MapiReadMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  402.   lpszMessageID: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  403.   var lppMessage: PMapiMessage): Cardinal;
  404. begin
  405.   InitMapi;
  406.   if @ReadMail = nil then
  407.     @ReadMail := GetProcAddress(MAPIModule, 'MAPIReadMail');
  408.   if @ReadMail <> nil then
  409.     Result := ReadMail(lhSession, ulUIParam, lpszMessageID, flFlags,
  410.       ulReserved, lppMessage)
  411.   else Result := 1;
  412. end;
  413.  
  414. function MapiSaveMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  415.   var lpMessage: TMapiMessage; flFlags: FLAGS; ulReserved: Cardinal;
  416.   lpszMessageID: LPSTR): Cardinal;
  417. begin
  418.   InitMapi;
  419.   if @SaveMail = nil then
  420.     @SaveMail := GetProcAddress(MAPIModule, 'MAPISaveMail');
  421.   if @SaveMail <> nil then
  422.     Result := SaveMail(lhSession, ulUIParam, lpMessage, flFlags, ulReserved,
  423.       lpszMessageID)
  424.   else Result := 1;
  425. end;
  426.  
  427. function MapiDeleteMail(lhSession: LHANDLE; ulUIParam: Cardinal;
  428.   lpszMessageID: LPSTR; flFlags: FLAGS;
  429.   ulReserved: Cardinal): Cardinal;
  430. begin
  431.   InitMapi;
  432.   if @DeleteMail = nil then
  433.     @DeleteMail := GetProcAddress(MAPIModule, 'MAPIDeleteMail');
  434.   if @DeleteMail <> nil then
  435.     Result := DeleteMail(lhSession, ulUIParam, lpszMessageID, flFlags,
  436.       ulReserved)
  437.   else Result := 1;
  438. end;
  439.  
  440. function MapiFreeBuffer(pv: Pointer): Cardinal;
  441. begin
  442.   InitMapi;
  443.   if @FreeBuffer = nil then
  444.     @FreeBuffer := GetProcAddress(MAPIModule, 'MAPIFreeBuffer');
  445.   if @FreeBuffer <> nil then
  446.     Result := FreeBuffer(pv)
  447.   else Result := 1;
  448. end;
  449.  
  450. function MapiAddress(lhSession: LHANDLE; ulUIParam: Cardinal;
  451.   lpszCaption: LPSTR; nEditFields: Cardinal; lpszLabels: LPSTR;
  452.   nRecips: Cardinal; var lpRecips: TMapiRecipDesc; flFlags: FLAGS;
  453.   ulReserved: Cardinal; lpnNewRecips: PULONG;
  454.   var lppNewRecips: PMapiRecipDesc): Cardinal;
  455. begin
  456.   InitMapi;
  457.   if @Address = nil then
  458.     @Address := GetProcAddress(MAPIModule, 'MAPIAddress');
  459.   if @Address <> nil then
  460.     Result := Address(lhSession, ulUIParam, lpszCaption, nEditFields,
  461.       lpszLabels, nRecips, lpRecips, flFlags, ulReserved, lpnNewRecips,
  462.       lppNewRecips)
  463.   else Result := 1;
  464. end;
  465.  
  466. function MapiDetails(lhSession: LHANDLE; ulUIParam: Cardinal;
  467.   var lpRecip: TMapiRecipDesc; flFlags: FLAGS; ulReserved: Cardinal): Cardinal;
  468. begin
  469.   InitMapi;
  470.   if @Details = nil then
  471.     @Details := GetProcAddress(MAPIModule, 'MAPIDetails');
  472.   if @Details <> nil then
  473.     Result := Details(lhSession, ulUIParam, lpRecip, flFlags, ulReserved)
  474.   else Result := 1;
  475. end;
  476.  
  477. function MapiResolveName(lhSession: LHANDLE; ulUIParam: Cardinal;
  478.   lpszName: LPSTR; flFlags: FLAGS; ulReserved: Cardinal;
  479.   var lppRecip: PMapiRecipDesc): Cardinal;
  480. begin
  481.   InitMapi;
  482.   if @ResolveName = nil then
  483.     @ResolveName := GetProcAddress(MAPIModule, 'MAPIResolveName');
  484.   if @ResolveName <> nil then
  485.     Result := ResolveName(lhSession, ulUIParam, lpszName, flFlags,
  486.       ulReserved, lppRecip)
  487.   else Result := 1;
  488. end;
  489.  
  490. initialization
  491. finalization
  492.   if MAPIModule <> 0 then FreeLibrary(MAPIModule);
  493. end.
  494.